package com.ky.serialport.sensor.root;

import com.ky.serialport.bean.ComBean;
import com.ky.serialport.utils.MyFunc;

/**
 * ACK 格式相同，所以统一
 */
public class RootACK {
    public ComBean comBean;
    public Long time = 0L;
    public int type = 0; //传感器类型
    public int index = -1; //传感器序号
    public int power = 0; //电量
    public int signal = 0; //信号

    public RootACK() {

    }

    public RootACK(ComBean comBean ) {
        caculate(comBean);
    }

    public RootACK caculate(ComBean comBean) {
        byte[] buffer = comBean.recData;
        int len = buffer.length;
        this.comBean = comBean;
        time = comBean.recTime;
        type = buffer[9];
        index = buffer[10];
        power = MyFunc.getPower(buffer[len-4],buffer[len-3]);
        signal = MyFunc.getSignal(buffer[len-2]); //测试信号
        return this;
    }
}
